﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


public class FeedbackResponse
{

    private int feedbackID;
    private String responseCourse1,responseCourse2,responseCourse3,responseCourse4,responseCourse5;
    private String responseInstruction1, responseInstruction2, responseInstruction3, responseInstruction4;
    private String responseTutLab1;
    private String responseTAOpen;
    private String responseOpen1,responseOpen2,responseOpen3;

	public FeedbackResponse()
	{
		
	}

    public void setFeedbackID(int feedbackID)
    {
        this.feedbackID = feedbackID;
    }

    public void setCourseResponses(String responseCourse1, String responseCourse2, String responseCourse3, String responseCourse4, String responseCourse5)
    {
        this.responseCourse1 = responseCourse1;
        this.responseCourse2 = responseCourse2;
        this.responseCourse3 = responseCourse3;
        this.responseCourse4 = responseCourse4;
        this.responseCourse5 = responseCourse5;
    }

    public void setInstructorResponses(String responseInstruction1, String responseInstruction2, String responseInstruction3, String responseInstruction4)
    {
        this.responseInstruction1 = responseInstruction1;
        this.responseInstruction2 = responseInstruction2;
        this.responseInstruction3 = responseInstruction3;
        this.responseInstruction4 = responseInstruction4;
    }

    public void setTutLabResponse(String responseTutLab1)
    {
        this.responseTutLab1 = responseTutLab1;
    }

    public void setTAOpenResponse(String responseTAOpen)
    {
        this.responseTAOpen = responseTAOpen;
    }

    public void setOpenResponses(String responseOpen1, String responseOpen2, String responseOpen3)
    {
        this.responseOpen1 = responseOpen1;
        this.responseOpen2 = responseOpen2;
        this.responseOpen3 = responseOpen3;
    }



    public int saveResponse(String student_ID)
    {
        try
        {
            String sql = "INSERT INTO response VALUES('"
                                        + feedbackID + "',"
                                        + responseCourse1 + ","
                                        + responseCourse2 + ","
                                        + responseCourse3 + ","
                                        + responseCourse4 + ","
                                        + responseCourse5 + ","
                                        + "null, null,"
                                        + responseInstruction1 + ","
                                        + responseInstruction2 + ","
                                        + responseInstruction3 + ","
                                        + responseInstruction4 + ","
                                        + "null, null,"
                                        + responseTutLab1 + ","
                                        + "null, '"
                                        + responseTAOpen + "','"
                                        + responseOpen1 + "','"
                                        + responseOpen2 + "','"
                                        + responseOpen3 + "',"
                                        + "null, null)";

            DbUtilities dbUtil = new DbUtilities(sql);
            dbUtil.retrieveInfo();
            sql = "UPDATE student set Filled_Feedback = 1 WHERE Student_Email='" + student_ID + "@iiitd.ac.in' AND Feedback_ID=" + feedbackID;
            dbUtil = new DbUtilities(sql);
            dbUtil.writeInfo();
            return 1;
        }
        catch (Exception ex)
        {
           return 2;
        }
    }
}